#ifndef PictPort_First
#define PictPort_First
#ifdef __GNUG__
#pragma interface
#endif

#include "PrintPort.h"
#include "MemBuf.h"

class Picture;
class Bitmap;

//---- PictPort ----------------------------------------------------------------

class PictPort: public PrintPort {
public:
	MetaDef(PictPort);
	PictPort(Picture*);
	~PictPort();

	Picture *GetPicture();
	void DevOpenPage(int n);
	void DevClosePage();
	void DevClip(const Rectangle&);
	void DevStrokeLine(int, const Rectangle&, GrLineCap, const Point&,
													const Point&);
	void DevShowChar(Font *fdp, const Point &delta, Rune c, const Rectangle&);
	void DevStrokeRect(int, const Rectangle&);
	void DevFillRect(const Rectangle&);
	void DevStrokeOval(int, const Rectangle&);
	void DevFillOval(const Rectangle&);
	void DevStrokeRRect(int, const Rectangle&, const Point&);
	void DevFillRRect(const Rectangle&, const Point&);
	void DevStrokeWedge(int, GrLineCap, const Rectangle&, int, int);
	void DevFillWedge(const Rectangle&, int, int);
	void DevStrokePolygon(const Rectangle&, Point*, int, GrPolyType t,
				int, GrLineCap);
	void DevFillPolygon(const Rectangle&, Point*, int, GrPolyType t);
	void DevShowBitmap(const Rectangle&, Bitmap*);
	void DevShowPicture(const Rectangle &r, Picture *pict);
	void DevGiveHint(int code, int len, void *vp);

protected:
	void PutByte(byte b);
	void PutCode(int c);
	void PutChar(char c);
	void PutShort(short s);
	void PutInt(int i);
	void PutPoint(byte code, const Point &p);
	void PutPos(const Point &pos);
	void PutRect(const Rectangle &r);
	void PutSize(int s);
	void PutCap(GrLineCap cap);
	void PutAngle(int s, int e);
	void PutDia(const Point &e);
	void PutInk();
	void PutObject(int code, Object *op);

protected:
	MemBuf *pagebuf;
	Point lastpos, lastdia, lastextent;
	Font *lastfont;
	int lastpsz, laststartangle, lastendangle;
	GrLineCap lastcap;
	Ink *lastink2;
	ObjArray *map;
	Picture *pict;
};

inline Picture *PictPort::GetPicture()
	{ return pict; }
inline void PictPort::PutByte(byte b)
	{ pagebuf->sputc(b); }
inline void PictPort::PutCode(int c)
	{ pagebuf->sputc(c); }
inline void PictPort::PutChar(char c)
	{ pagebuf->sputc(c); }

#endif
